﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Message/Message.master" AutoEventWireup="true" CodeBehind="MessageReceived.aspx.cs" Inherits="HRdex_Final.Message.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div align="center">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="btnSearch"
            runat="server" Text="Search" onclick="btnSearch_Click" />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" CellPadding="3" DataKeyNames="MessageID" 
            DataSourceID="formMessege" 
            onselectedindexchanged="GridView1_SelectedIndexChanged" 
            style="text-align: center; margin-right: 4px;" Width="703px" 
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" 
            BorderWidth="1px" AllowSorting="True">
            <Columns>
                <asp:BoundField DataField="MessageID" HeaderText="MessageID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="MessageID" 
                    Visible="False" />
                <asp:ButtonField CommandName="Select" HeaderText="View" Text="View" />
                <asp:BoundField DataField="fulname" HeaderText="From" ReadOnly="True" 
                    SortExpression="fulname" />
                <asp:BoundField DataField="Subject" HeaderText="Subject" 
                    SortExpression="Subject" />
                <asp:BoundField DataField="DateTime" HeaderText="Date" 
                    SortExpression="DateTime" />
                <asp:BoundField DataField="AttachmentName" HeaderText="Attachment" 
                    SortExpression="AttachmentName" />
                <asp:BoundField DataField="Parent" HeaderText="Parent" 
                    SortExpression="Parent" Visible="False" />
                <asp:BoundField DataField="catMessegeName" HeaderText="Message Type" 
                    SortExpression="catMessegeName" />
                <asp:BoundField DataField="Readed" HeaderText="Read" ReadOnly="True" 
                    SortExpression="Readed" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
        </asp:GridView>
        <asp:SqlDataSource ID="formMessege" runat="server" 
            ConnectionString="<%$ ConnectionStrings:HRmainConnectionString %>" 
            
            
            SelectCommand="SELECT formMessegeSender.MessageID, formMessegeSender.Subject, formMessegeSender.DateTime, formMessegeSender.AttachmentName, formMessegeSender.Parent, formEmployees.LastName + ', ' + formEmployees.FirstName AS fulname, catMessege.catMessegeName, formMessegeSender.Readed FROM formMessegeSender INNER JOIN formEmployees ON formMessegeSender.fromEmpID = formEmployees.EmployeeID INNER JOIN catMessege ON formMessegeSender.catMessegeID = catMessege.catMessegeID WHERE (formMessegeSender.EmployeeID = @empid) ORDER BY formMessegeSender.DateTime DESC">
            <SelectParameters>
                <asp:SessionParameter Name="empid" SessionField="EmployeeID" />
            </SelectParameters>
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:HRmainConnectionString %>" 
            
            SelectCommand="SELECT formMessegeSender.Subject, formMessegeSender.Description, formMessegeSender.DateTime, formEmployees.LastName + ', ' + formEmployees.FirstName AS fulname, catMessege.catMessegeName, formMessegeSender.EmployeeID FROM formMessegeSender INNER JOIN formEmployees ON formMessegeSender.EmployeeID = formEmployees.EmployeeID INNER JOIN catMessege ON formMessegeSender.catMessegeID = catMessege.catMessegeID WHERE (formMessegeSender.MessageID = @msg)" 
            InsertCommand="INSERT INTO formMessegeSender(Subject, Description, DateTime, EmployeeID, catMessegeID, fromEmpID, Readed) VALUES (@subj, @desc , @time, @emp, @type, @from , 0)">       
        </asp:SqlDataSource>
    </div>
    <div>
        
        <br />
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:HRmainConnectionString %>" 
            SelectCommand="SELECT formMessegeSender.MessageID, formMessegeSender.Subject, formMessegeSender.DateTime, formMessegeSender.AttachmentName, formMessegeSender.Parent, formEmployees.LastName + ', ' + formEmployees.FirstName AS fulname, catMessege.catMessegeName FROM formMessegeSender INNER JOIN formEmployees ON formMessegeSender.EmployeeID = formEmployees.EmployeeID INNER JOIN catMessege ON formMessegeSender.catMessegeID = catMessege.catMessegeID WHERE (formMessegeSender.EmployeeID = @empid) ORDER BY formMessegeSender.DateTime Desc">
            <SelectParameters>
                <asp:SessionParameter Name="empid" SessionField="EmployeeID" />
            </SelectParameters>
        </asp:SqlDataSource>
        
    </div>
</asp:Content>
